package handler;

import java.util.ArrayList;
import java.util.List;

public class TableEntity {

	private String tableName;
	
	private String tableCaption;
	
	private String type;
	
	private List<Column>  columns ;
	

	/**  
	 * 获取tableName  
	 * @return tableName tableName  
	 */
	public String getTableName() {
		return tableName;
	}

	/**  
	 * 设置tableName  
	 * @param tableName tableName  
	 */
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}



	/**  
	 * 获取tableCaption  
	 * @return tableCaption tableCaption  
	 */
	public String getTableCaption() {
		return tableCaption;
	}

	/**  
	 * 设置tableCaption  
	 * @param tableCaption tableCaption  
	 */
	public void setTableCaption(String tableCaption) {
		this.tableCaption = tableCaption;
	}

	/**  
	 * 获取type  
	 * @return type type  
	 */
	public String getType() {
		return type;
	}

	/**  
	 * 设置type  
	 * @param type type  
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**  
	 * 获取columns  
	 * @return columns columns  
	 */
	public List<Column> getColumns() {
		return columns;
	}

	/**  
	 * 设置columns  
	 * @param columns columns  
	 */
	public void setColumns(List<Column> columns) {
		List<Column> cols = new ArrayList<Column>();
		List<Column> tempcols = new ArrayList<Column>();
		Column caption = null;
		for(Column col : columns){
			if(col.isPrimayKey()){
				cols.add(col);
			}else if(col.isCaptionKey()){
				caption = col;
			}else{
				tempcols.add(col);
			}
		}
		cols.add(caption);
		for(Column col : tempcols){
			cols.add(col);
		}
		
		this.columns = cols;
	}
	
	
}
